import { getServiceProList } from '@/static/js/servicePro.js'
export default {
  data() {
    return {
      list: [],
      page: 1,
      noMore: 'noMore'
    };
  },
  onLoad(e) {
    this.getServiceProList()
  },
  methods: {
    goDetails(item) {
      uni.navigateTo({ url: '/pages/servicePro/serviceInfo?id=' + item.id })
    },
    //请求服务商列表
    getServiceProList() {
      getServiceProList({
        city_code: "",
        one_cate_id: '',
        page: this.page,
        pageSize: 10,
        sort: 0,
        third_cate_id: '',
        two_cate_id: '',
      }).then(res => {
        if (res.code == 1) {
          if (res.data.list.length == 0 || res.data.list.length < 10) {
            this.noMore = 'noMore'
          } else {
            this.noMore = 'loadMore'
          }
          this.list.push(...res.data.list)
        }
      })
      uni.stopPullDownRefresh()
    },
  },

  //上拉触底
  onReachBottom() {
    if (this.noMore == 'noMore') return
    this.page++
    this.getServiceProList()
  },
  //下拉刷新
  onPullDownRefresh() {
    this.page = 1
    this.list = []
    this.getServiceProList()
  }
}